// Tester1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "../EEGAnalysis/EEGAnalysis.h"


#define PI 3.1415926535897932384626
#define F(x) (2+3*sin(2*PI*10*(x))+3.3*sin(2*PI*20*(x)))
#define DB_EPS 1e-12
#define TIME 1200
#define SAMPLER 500

#define _TEST
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
	//fnEEGAnalysis();
	//DS_SetRef(4);

	time_t      szClock;
	// Get time in seconds
	time( &szClock );
	std::cout<< ((int*)&szClock)[1]+((int*)&szClock)[0]<<endl;

	DLL_Init();

	DS_SetSamplingRate(SAMPLER);

	DWORD singleTime=GetTickCount();  
	DS_AddChannel(8);
	for(double i=0;i<TIME+DB_EPS;i+=0.002)//sampling rate=1000
		DS_AddSingleData(F(i));
	DS_EndChannel();
	singleTime=GetTickCount()-singleTime; 
	std::cout<<"add ch. "<< singleTime <<"ms"<<endl;

	singleTime=GetTickCount();
	DS_AddChannel(17);
	for(double i=0;i<TIME+DB_EPS;i+=0.002)//sampling rate=1000
		DS_AddSingleData(2*F(i)+rand()/(double)RAND_MAX*32.2);
	DS_EndChannel();
	singleTime=GetTickCount()-singleTime; 
	std::cout<<"add ch. "<< singleTime <<"ms"<<endl;

	int chs[]={8,17};

#ifdef _TEST
	singleTime=GetTickCount();  

	FFT_SetParameters(chs,2,0,TIME*SAMPLER-1);
	FFT_StartCalc();
	FFT_ShowFFTGraph();

	singleTime=GetTickCount()-singleTime; 
	std::cout<<"add ch. "<< singleTime <<"ms"<<endl;
#endif

	int resultID;
#ifdef _TEST0
	singleTime=GetTickCount();  

	DSA_SetOnceParameters(chs,2,0,TIME*SAMPLER-1);
	resultID = DSA_StartCalc();
	DSA_AddViewW(resultID, L"ha");
	DSA_ShowDSAGraph();

	singleTime=GetTickCount()-singleTime; 
	std::cout<<"add ch. "<< singleTime <<"ms"<<endl;
#endif


#ifdef _TEST
	singleTime=GetTickCount();  

	DSA_SetOnceParameters(chs,1,0,TIME*SAMPLER-1);
	resultID = DSA_StartCalc();
	DSA_AddViewW(resultID, L"ha");
	DSA_SetOnceParameters(chs+1,1,0,TIME*SAMPLER-1);
	resultID = DSA_StartCalc();
	DSA_AddViewW(resultID, L"ha");
	DSA_ShowDSAGraph();

	singleTime=GetTickCount()-singleTime; 
	std::cout<<"add ch. "<< singleTime <<"ms"<<endl;
#endif

	DLL_Finish();

	system("pause");
	return 0;
}

